package com.lifeng.springevent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * Created by lifeng on 2019/8/5.
 * 监听某个事件 方式1
 */
@Component
public class SubmitOrderListener {
    private static final Logger log = LoggerFactory.getLogger(SubmitOrderListener.class);

    @Async //可以开启异步
    @EventListener(SubmitOrderEvent.class)
    public void defaultSubmitOrderListener(SubmitOrderEvent event) {
        log.info("SubmitOrderEvent事件触发");
        log.info(event.getId()+"=="+event.getUser().getPassword());
    }
}
